#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution
{
public:
	int majorityElement(vector<int> &num) {
		int vote=num[0];
		int count=1;
		for(int i=1;i<num.size();++i)
		{
			if(count==0)
			{
				vote=num[i];
				count=1;
				continue;
			}
			if(num[i]!=vote)
				count--;
			else
				count++;
		}
		return vote;
	}
};

int main()
{
	Solution solution;
	int a[]={1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
	int a_size=sizeof(a)/sizeof(a[0]);
	vector<int> num(a,a+a_size);
	cout<<solution.majorityElement(num)<<endl;
}